//
//  H_TabBarController.m
//  Honey
//
//  Created by 贾亚涵 on 16/3/17.
//  Copyright © 2016年 贾亚涵. All rights reserved.
//

#import "H_TabBarController.h"
#import "H_NavigationController.h"
#import "H_HoneyViewController.h"
#import "H_TimeViewController.h"
#import "H_MoreViewController.h"


@interface H_TabBarController ()

@end

@implementation H_TabBarController

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
    
    [self setUpAllChildVC];
}

//添加所有控制器的方法
-(void)setUpAllChildVC
{
    H_HoneyViewController * honeyVC = [H_HoneyViewController new];
    H_TimeViewController * findVC = [H_TimeViewController new];
    H_MoreViewController * moreVC = [H_MoreViewController new];
    
    [self setUpOneChildVC:honeyVC TabTitle:@"蜜糖" NavTitle:@"我的蜜糖" ImageName:@"ln_tab_1" SelectImageName:@"honey_tab1"];
    [self setUpOneChildVC:findVC TabTitle:@"时光" NavTitle:@"蜜糖时光" ImageName:@"ln_tab_2" SelectImageName:@"honey_tab2"];
    [self setUpOneChildVC:moreVC TabTitle:@"更多" NavTitle:@"发现更多" ImageName:@"ln_tab_4" SelectImageName:@"honey_tab3"];
    
    
    
}


//添加一个控制器的方法
-(void)setUpOneChildVC:(UIViewController *)vc TabTitle:(NSString *)TabTitle NavTitle:(NSString *)NavTitle ImageName:(NSString *)imageName SelectImageName:(NSString *)selectImageName
{
    H_NavigationController * nav = [[H_NavigationController alloc] initWithRootViewController:vc];
    
    nav.title = TabTitle;
    
    //只能用vc来添加Nav上的文字
    vc.navigationItem.title = NavTitle;
    
    nav.tabBarItem.image = [[UIImage imageNamed:imageName] imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal];
    nav.tabBarItem.selectedImage = [[UIImage imageNamed:selectImageName] imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal];
    
    //点击tabBar字体的颜色
    [nav.tabBarItem setTitleTextAttributes:[NSDictionary dictionaryWithObjectsAndKeys:[UIColor colorWithRed:246/255.0 green:157/255.0 blue:182/255.0 alpha:1],NSForegroundColorAttributeName,nil] forState:UIControlStateSelected];
    
    
    [self addChildViewController:nav];
    
}

@end
